package com.lee.dto.base;


import javax.servlet.http.HttpServletRequest;

/**
 * request请求的参数分装对象
 * User:liwei
 * Date:2017/8/31
 * Time:14:45
 */
public class RequestInfo {
    private String sign;
    private String aceessKey;
    private String method;
    private String accessToken;
    private String version;
    private String timestamp;
    private String body;

    private final static String SIGN = "sign";
    private final static String ACEESSKEY = "aceessKey";
    private final static String METHOD = "method";
    private final static String ACCESSTOKEN = "accessToken";
    private final static String VERSION = "version";
    private final static String TIMESTAMP = "timestamp";
    private final static String BODY = "body";

    /**
     * 根据request请求初始化
     * @param request
     * @return
     */
    public static RequestInfo init(HttpServletRequest request){
        RequestInfo requestInfo = new RequestInfo();
        requestInfo.setAccessToken(request.getParameter(ACCESSTOKEN));
        requestInfo.setSign(request.getParameter(SIGN));
        requestInfo.setAceessKey(request.getParameter(ACEESSKEY));
        requestInfo.setMethod(request.getParameter(METHOD));
        requestInfo.setVersion(request.getParameter(VERSION));
        requestInfo.setTimestamp(request.getParameter(TIMESTAMP));
        requestInfo.setBody(request.getParameter(BODY));
        return requestInfo;
    }

    public String getSign() {
        return sign;
    }

    public void setSign(String sign) {
        this.sign = sign;
    }

    public String getAceessKey() {
        return aceessKey;
    }

    public void setAceessKey(String aceessKey) {
        this.aceessKey = aceessKey;
    }

    public String getMethod() {
        return method;
    }

    public void setMethod(String method) {
        this.method = method;
    }

    public String getAccessToken() {
        return accessToken;
    }

    public void setAccessToken(String accessToken) {
        this.accessToken = accessToken;
    }

    public String getVersion() {
        return version;
    }

    public void setVersion(String version) {
        this.version = version;
    }

    public String getTimestamp() {
        return timestamp;
    }

    public void setTimestamp(String timestamp) {
        this.timestamp = timestamp;
    }

    public String getBody() {
        return body;
    }

    public void setBody(String body) {
        this.body = body;
    }
}
